package com.ywjt.platformbusiness.cart.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ywjt.platformbusiness.R;
import com.ywjt.platformbusiness.cart.CartListModel;

import java.util.List;

public class CartGoodsAdapter extends BaseQuickAdapter<CartListModel.ResultDTO.ShopCartListDTO, BaseViewHolder> {

    public CartGoodsAdapter(@Nullable List<CartListModel.ResultDTO.ShopCartListDTO> data) {
        super(R.layout.item_cart_c, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CartListModel.ResultDTO.ShopCartListDTO item) {
        ImageView ivGoodsImg=helper.getView(R.id.ivGoodsImg);
        Glide.with(mContext).load(item.getCommodityCover())
                .placeholder(R.mipmap.default_image)
                .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
                .into(ivGoodsImg);
    helper.setText(R.id.tvGoodsName,item.getCommodityName());
    helper.setText(R.id.tvGoodPrice,"¥"+item.getCommodityPrice());
    helper.setText(R.id.tvNum,item.getNum()+"");

    }
}
